<div class="addresses form">
    <?php echo $this->Form->create('Address'); ?>
    <fieldset>
        <legend><?php echo __('Address'); ?></legend>
        <?php
        echo $this->Form->input('Address.0.user_id', array('type' => 'hidden', 'value' => $_SESSION['UserID']));
        echo $this->Form->input('Address.0.is_primary', array('type' => 'hidden', 'value' => 1));
        echo $this->Form->input('Address.0.mailing_address', array('label' => 'Primary Mailing Address'));
        echo $this->Form->input('Address.0.apt_no');
        echo $this->Form->input('Address.0.city');
        echo $this->Form->input('Address.0.state_id');
        echo $this->Form->input('Address.0.zip');
        echo $this->Form->input('Address.0.no_of_aduldts');
        echo $this->Form->input('Address.0.no_of_children');
        echo $this->Form->input('Address.0.is_allowed_mail', array('label' => 'Do you want mailings at this address?'));
        ?>
    </fieldset>
    <div id="address-form-div">
        <a href="#" id="add-address" onclick="return false;">Add Secondary Address</a>
    </div>
    <?php echo $this->Form->input('Save Draft',array('id'=>'save-draft','type'=>'button')); ?>
    <?php echo $this->Form->end(__('Next')); ?>
</div>
<script>
    $().ready(function() {
        $("#content").on('click', "#add-address", function() {
            $.ajax({url: "<?php echo $this->Html->url(array('controller' => 'users', 'action' => 'em_secondary_address', 'em' => true)); ?>", success: function(result) {
                    $("#address-form-div").html(result);
                }
            });
        });
        $("#content").on("click", ".remove-address", function() {
            var addrHtml = '<a href="#" id="add-address" onclick="return false;">Add Secondary Address</a>';
            $("#address-form-div").html(addrHtml);
        });
    });
</script>